package com.ityu.service.impl;

import com.ityu.mapper.ReportMapper;
import com.ityu.pojo.report.ClazzOption;
import com.ityu.pojo.report.JobOption;
import com.ityu.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

@Slf4j
@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private ReportMapper reportMapper;

    @Override
    public JobOption EmpJobData() {
        log.info("-----empJobDataService-----统计员工职位");
        List<Map<String,Object>> list = reportMapper.EmpJobData();
        List<Object> jobList = list.stream().map(data -> data.get("job")).toList();
        List<Object> dataList = list.stream().map(data -> data.get("total")).toList();
        return new JobOption(jobList,dataList);
    }

    @Override
    public List<Map> EmpGenderData() {
        log.info("-----empGenderDataService-----统计员工性别");
        return reportMapper.EmpGenderData();
    }

    @Override
    public List<Map> StudentDegreeData() {
        log.info("-----StudentDegreeDataService-----统计学生学历");
        return reportMapper.StudentDegreeData();
    }

    @Override
    public ClazzOption ClazzData() {
        log.info("-----ClazzDataService-----统计班级");
        List<Map<String,Object>> list = reportMapper.ClazzData();
        List<Object> clazzList = list.stream().map(data -> data.get("clazz")).toList();
        List<Object> dataList = list.stream().map(data -> data.get("total")).toList();
        return new ClazzOption(clazzList,dataList);
    }
}
